package com.oscar.ehome.presenter;

import com.oscar.ehome.bean.WeclomeBean;
import com.oscar.ehome.bean.pagebean.DiaoChaInfo;
import com.oscar.ehome.bean.pagebean.StudyDetialBean;
import com.oscar.ehome.model.HttpModel;
import com.oscar.ehome.model.HttpModelImple;
import com.oscar.ehome.model.OnHttpListener;
import com.oscar.ehome.view.pageview.view.DiaoChaView;
import com.oscar.ehome.view.welcomeview.WeclomeView;

/**
 * author: MengWanhe
 * date: On 2017/6/6
 */

public class WeclomePresenter {


    HttpModel httpModel;
    WeclomeView weclomeView;
    DiaoChaView diaochaview;
    public WeclomePresenter(WeclomeView weclomeView) {
        this.weclomeView = weclomeView;
        httpModel = new HttpModelImple();
    }
    public WeclomePresenter(DiaoChaView diaochaview) {
        this.diaochaview = diaochaview;
        httpModel = new HttpModelImple();
    }

    /**
     * xuexiguodu   daiwanshan
     */
    public void getwenjianInfo(String token) {

        httpModel.getWenJianInfo(token,new OnHttpListener<StudyDetialBean>() {
            @Override
            public void onSuccess(StudyDetialBean obj) {

                if (weclomeView != null)
                    weclomeView.getbaojianjufile(obj);
            }

            @Override
            public void onError(String msg) {


            }

            @Override
            public void onFailure() {


            }
        });
    }
    /**
     * xuexiguodu   daiwanshan
     */
    public void getDiaochaInfo(String token) {

        httpModel.getDiaoChaInfo(token,new OnHttpListener<DiaoChaInfo>() {
            @Override
            public void onSuccess(DiaoChaInfo obj) {

                if (diaochaview != null)
                    diaochaview.getDiaocharesult(obj);
            }

            @Override
            public void onError(String msg) {
                if (diaochaview != null)
                    diaochaview.erry(msg);
            }

            @Override
            public void onFailure() {
                if (diaochaview != null)
                    diaochaview.erroy();
            }
        });
    }
    public void getwelDiaochaInfo(String token) {

        httpModel.getDiaoChaInfo(token,new OnHttpListener<DiaoChaInfo>() {
            @Override
            public void onSuccess(DiaoChaInfo obj) {

                if (weclomeView != null)
                    weclomeView.getDiaocharesult(obj);
            }

            @Override
            public void onError(String msg) {

            }

            @Override
            public void onFailure() {
            }
        });
    }
    /**
     * xuexiguodu   daiwanshan
     */
    public void putshuju(String json,String token) {

        httpModel.getputshuju(json,token,new OnHttpListener<String>() {
            @Override
            public void onSuccess(String obj) {

                if (diaochaview != null)
                    diaochaview.putshuju(obj);
            }

            @Override
            public void onError(String msg) {
                if (diaochaview != null)
                    diaochaview.erry(msg);
            }

            @Override
            public void onFailure() {
                if (diaochaview != null)
                    diaochaview.erroy();
            }
        });
    }
    /**
     * 获取图片
     */
    public void getImg(String token) {
        httpModel.getImage(token, new OnHttpListener<WeclomeBean>() {
            @Override
            public void onSuccess(WeclomeBean obj) {
                if (weclomeView != null)
                    weclomeView.moveToIndex(obj);
            }
            @Override
            public void onError(String msg) {
                if (weclomeView != null)
                    weclomeView.showToast(msg);
            }
            @Override
            public void onFailure() {
                if (weclomeView != null)
                    weclomeView.showToast("失败了");
            }
        });
    }
}
